package eteam.aps.systeminterface.service;

import eteam.aps.common.QueryResult;
import eteam.aps.common.R;
import eteam.aps.common.exceptions.AuthException;
import eteam.aps.systeminterface.model.dto.RoleDto;
import eteam.aps.systeminterface.model.entity.ModuleoperEntity;
import eteam.aps.systeminterface.model.entity.UserEntity;
import eteam.aps.systeminterface.model.reqparam.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * 角色服务
 */
public interface IRoleController {
    /**
     * 分页查询角色列表
     *
     * @param requestDto: 查询参数
     * @return
     */
    @GetMapping(value = "/api/role/querypagelist")
    R<QueryResult<UserEntity>> queryRolePageList(@Validated QueryRoleParam requestDto) throws Exception, AuthException;

    /**
     * 新增角色
     *
     * @param roleDto: 角色信息
     * @return
     */
    @PostMapping(value = "/api/role/createrole")
    R createRole(@Validated(Insert.class) @RequestBody RoleDto roleDto) throws Exception, AuthException;

    /**
     * 更新角色
     *
     * @param roleDto: 角色信息
     * @return
     */
    @PostMapping(value = "/api/role/updaterole")
    R updateRole(@Validated(Update.class) @RequestBody RoleDto roleDto) throws Exception, AuthException;

    /**
     * 删除角色
     *
     * @param roleParam: 角色Id参数
     * @return
     */
    @PostMapping(value = "/api/role/deleterole")
    R deleteRole(@Validated @RequestBody IdParam roleParam) throws Exception, AuthException;

    /**
     * 变更状态，启用/禁用
     *
     * @param changeParam: 变更状态参数
     * @return
     */
    @PostMapping(value = "/api/role/changerolestate")
    R changeRoleState(@Validated @RequestBody ChangeStateParam changeParam) throws Exception, AuthException;

    /**
     * 根据角色ID获取所属用例列表
     *
     * @param roleid: 角色ID
     * @return
     */
    @GetMapping(value = "/api/role/getucbyroleid")
    R<List<ModuleoperEntity>> getUcByRoleId(@NotBlank(message = "角色ID为空") String roleid) throws Exception, AuthException;

    /**
     * 保存角色用例
     *
     * @param roleUcParam: 角色用例请求参数
     * @return
     */
    @PostMapping(value = "/api/role/setroleuc")
    R setRoleUc(@Validated @RequestBody RoleUcParam roleUcParam) throws Exception, AuthException;

    /**
     * 根据机构ID和机构类别，获取所属角色列表
     *
     * @param userRoleParam
     * @return
     */
    @GetMapping(value = "/api/role/getrolelistbytype")
    R<List<UserEntity>> getRoleListByType(@Validated UserRoleParam userRoleParam) throws Exception, AuthException;

    /**
     * 获取角色列表
     *
     * @return
     */
    @GetMapping(value = "/api/role/getrolelist")
    R<List<UserEntity>> getRoleList() throws Exception, AuthException;

    /**
     * 根据用户ID，获取绑定角色列表
     *
     * @param userid: 用户ID
     * @return
     */
    @GetMapping(value = "/api/role/getrolelistbyuserid")
    R<List<UserEntity>> getRoleListByUserId(@NotBlank(message = "用户ID为空") String userid) throws Exception, AuthException;

    /**
     * 保存角色用户
     *
     * @param roleUserParam: 角色用户请求参数
     * @return
     */
    @PostMapping(value = "/api/role/setroleuser")
    R setRoleUser(@Validated @RequestBody RoleUserParam roleUserParam) throws Exception, AuthException;
}
